home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / DYNAMN.PAK / DMVIEW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.9 KB  |  144 lines

  1. // dmview.cpp
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. //
  13. // Purpose: implementation of the CDynaMenuView class
  14. //
  15. // Functions:
  16. //   Most of this file was generated by AppWizard.  The functions
  17. //   which contain code specific to this sample are:
  18. //
  19. //      CDynaMenuView::OnDraw()             -- draw the view contents
  20.  
  21. #include "stdafx.h"
  22. #include "dynamenu.h"
  23.  
  24. #include "dmdoc.h"
  25. #include "dmview.h"
  26.  
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDynaMenuView
  34.  
  35. IMPLEMENT_DYNCREATE(CDynaMenuView, CView)
  36.  
  37. BEGIN_MESSAGE_MAP(CDynaMenuView, CView)
  38.     //{{AFX_MSG_MAP(CDynaMenuView)
  39.         // NOTE - the ClassWizard will add and remove mapping macros here.
  40.         //    DO NOT EDIT what you see in these blocks of generated code!
  41.     //}}AFX_MSG_MAP
  42.     // Standard printing commands
  43.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  44.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  45. END_MESSAGE_MAP()
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDynaMenuView construction/destruction
  49.  
  50. CDynaMenuView::CDynaMenuView()
  51. {
  52.     // TODO: add construction code here
  53. }
  54.  
  55. CDynaMenuView::~CDynaMenuView()
  56. {
  57. }
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CDynaMenuView drawing
  61.  
  62. //***********************************************************************
  63. // Function: CDynaMenuView::OnDraw()
  64. //
  65. // Purpose:
  66. //    OnDraw is called by the framework to render an image of the
  67. //    document.
  68. //
  69. //    We'll just put a string in the center of the client area for
  70. //    demonstration purposes.  The string is drawn in the current
  71. //    color selected for the associated document.
  72. //
  73. // Parameters:
  74. //    none
  75. //
  76. // Returns:
  77. //    none.
  78. //
  79. // Comments:
  80. //    see the CView::OnDraw() documentation for further information
  81. //
  82. //***********************************************************************
  83. void CDynaMenuView::OnDraw(CDC* pDC)
  84. {
  85.     CDynaMenuDoc* pDoc = GetDocument();
  86.     ASSERT_VALID(pDoc);
  87.  
  88.     // set color to use for text
  89.     int iColor   = pDoc->m_iColor;
  90.     COLORREF crf = CDynaMenuDoc::m_aColorDef[iColor].m_crf;
  91.  
  92.     pDC->SetTextColor(crf);
  93.     pDC->SetBkMode(TRANSPARENT);
  94.  
  95.     // output a string to the center of the client area
  96.     CRect rc;
  97.     GetClientRect(rc);
  98.     pDC->DrawText(_T("This text is displayed in the current color."), -1,
  99.                   rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  100.  
  101. }
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CDynaMenuView printing
  105.  
  106. BOOL CDynaMenuView::OnPreparePrinting(CPrintInfo* pInfo)
  107. {
  108.     // default preparation
  109.     return DoPreparePrinting(pInfo);
  110. }
  111.  
  112. void CDynaMenuView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  113. {
  114.     // TODO: add extra initialization before printing
  115. }
  116.  
  117. void CDynaMenuView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  118. {
  119.     // TODO: add cleanup after printing
  120. }
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CDynaMenuView diagnostics
  124.  
  125. #ifdef _DEBUG
  126. void CDynaMenuView::AssertValid() const
  127. {
  128.     CView::AssertValid();
  129. }
  130.  
  131. void CDynaMenuView::Dump(CDumpContext& dc) const
  132. {
  133.     CView::Dump(dc);
  134. }
  135.  
  136. CDynaMenuDoc* CDynaMenuView::GetDocument() // non-debug version is inline
  137. {
  138.     return STATIC_DOWNCAST(CDynaMenuDoc, m_pDocument);
  139. }
  140. #endif //_DEBUG
  141.  
  142. /////////////////////////////////////////////////////////////////////////////
  143. // CDynaMenuView message handlers
  144.